import { TweenMax } from "../../../../../com/greensock/TweenMax";
import { Bounce } from "../../../../../com/greensock/easing/Bounce";
type int = number;
//class DiceItem
    
    export  class DiceItem /* flash.display.Sprite */
    {
        constructor(arg1: Class)
        {
            
            this._rondomPoints = [];
            this.targetPoint = new Object /* flash.geom.Point */();
            this._animateMc = new arg1();
            this._animateMc.gotoAndStop(1);
            this.addChild(this._animateMc);
            return;
        }

        public get isOk(): Boolean
        {
            return this._state == 1;
        }

        public start(arg1: int=2, arg2: Boolean=true): void
        {
            var loc1=NaN;
            if (this.curTweenMax) 
            {
                this.curTweenMax.pause();
                this.curTweenMax.kill();
            }
            if (arg2 == false) 
            {
                this.x = this.targetPoint.x;
                this.y = this.targetPoint.y;
                this.onCompleteHandler();
                return;
            }
            if (arg1 != -1) 
            {
                loc1 = int(Math.abs(this.y - this.targetPoint.y) / 200 * 100) / 100;
                this._animateMc.gotoAndPlay("start");
                this.curTweenMax = TweenMax.to(this, loc1, {"bezier":[{"x": this.targetPoint.x, "y": this.targetPoint.y}], "orientToBezier": false, "ease": Bounce.easeOut, "onComplete": this.onCompleteHandler});
            }
            else if (this._timerOut == -1) 
            {
                this._animateMc.gotoAndPlay("start");
                this._timerOut = flash.utils.setTimeout(this.onCompleteHandler, 1000);
            }
            return;
        }

        /* internal  */onCompleteHandler(): void
        {
            this._animateMc.gotoAndStop(this._state);
            if (this.parent) 
            {
                this.parent.setChildIndex(this, 0);
            }
            if (typeof this.endPlayFunction === "function") 
            {
                this.endPlayFunction(this);
            }
            this._timerOut = -1;
            return;
        }

        public defaultState(): void
        {
            this._animateMc.gotoAndStop("default");
            return;
        }

        public setState(arg1: int): void
        {
            this._state = arg1;
            return;
        }

        public /* var */endPlayFunction: Function;

        /* internal */ /* var */_animateMc: Object /* flash.display.MovieClip */;

        /* internal */ /* var */curTweenMax: TweenMax;

        /* internal */ /* var */_rondomPoints: Array<any>;

        /* internal */ /* var */_timerOut: int=-1;

        public /* var */targetPoint: Object /* flash.geom.Point */;

        /* internal */ /* var */_state: int=-1;
    }
